package com.ruoyi.project.manage.detail.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.manage.detail.domain.ProjectInvestDetail;
import com.ruoyi.project.manage.detail.service.IProjectInvestDetailService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 资金落实明细记录Controller
 * 
 * @author fangkun
 * @date 2022-05-29
 */
@Controller
@RequestMapping("/manage/detail")
public class ProjectInvestDetailController extends BaseController
{
    private String prefix = "manage/detail";

    @Autowired
    private IProjectInvestDetailService projectInvestDetailService;

    @RequiresPermissions("manage:detail:view")
    @GetMapping()
    public String detail()
    {
        return prefix + "/detail";
    }

    /**
     * 查询资金落实明细记录列表
     */
    @RequiresPermissions("manage:detail:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ProjectInvestDetail projectInvestDetail)
    {
        startPage();
        List<ProjectInvestDetail> list = projectInvestDetailService.selectProjectInvestDetailList(projectInvestDetail);
        return getDataTable(list);
    }

    /**
     * 导出资金落实明细记录列表
     */
    @RequiresPermissions("manage:detail:export")
    @Log(title = "资金落实明细记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ProjectInvestDetail projectInvestDetail)
    {
        List<ProjectInvestDetail> list = projectInvestDetailService.selectProjectInvestDetailList(projectInvestDetail);
        ExcelUtil<ProjectInvestDetail> util = new ExcelUtil<ProjectInvestDetail>(ProjectInvestDetail.class);
        return util.exportExcel(list, "资金落实明细记录数据");
    }

    /**
     * 新增资金落实明细记录
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存资金落实明细记录
     */
    @RequiresPermissions("manage:detail:add")
    @Log(title = "资金落实明细记录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ProjectInvestDetail projectInvestDetail)
    {
        return toAjax(projectInvestDetailService.insertProjectInvestDetail(projectInvestDetail));
    }

    /**
     * 修改资金落实明细记录
     */
    @RequiresPermissions("manage:detail:edit")
    @GetMapping("/edit/{projectInvestDetailId}")
    public String edit(@PathVariable("projectInvestDetailId") Long projectInvestDetailId, ModelMap mmap)
    {
        ProjectInvestDetail projectInvestDetail = projectInvestDetailService.selectProjectInvestDetailByProjectInvestDetailId(projectInvestDetailId);
        mmap.put("projectInvestDetail", projectInvestDetail);
        return prefix + "/edit";
    }

    /**
     * 修改保存资金落实明细记录
     */
    @RequiresPermissions("manage:detail:edit")
    @Log(title = "资金落实明细记录", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ProjectInvestDetail projectInvestDetail)
    {
        return toAjax(projectInvestDetailService.updateProjectInvestDetail(projectInvestDetail));
    }

    /**
     * 删除资金落实明细记录
     */
    @RequiresPermissions("manage:detail:remove")
    @Log(title = "资金落实明细记录", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(projectInvestDetailService.deleteProjectInvestDetailByProjectInvestDetailIds(ids));
    }
}
